package com.health.web.controller.teahouse;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.health.common.annotation.Log;
import com.health.common.core.controller.BaseController;
import com.health.common.core.domain.AjaxResult;
import com.health.common.enums.BusinessType;
import com.health.teahouse.domain.DietData;
import com.health.teahouse.service.IDietDataService;
import com.health.common.utils.poi.ExcelUtil;
import com.health.common.core.page.TableDataInfo;

/**
 * 饮食数据信息Controller
 * 
 * @author ryang
 * @date 2024-02-11
 */
@RestController
@RequestMapping("/teahouse/dietData")
public class DietDataController extends BaseController
{
    @Autowired
    private IDietDataService dietDataService;

    /**
     * 查询饮食数据信息列表
     */
    @PreAuthorize("@ss.hasPermi('teahouse:dietData:list')")
    @GetMapping("/list")
    public TableDataInfo list(DietData dietData)
    {
        startPage();
        List<DietData> list = dietDataService.selectDietDataList(dietData);
        return getDataTable(list);
    }

    /**
     * 导出饮食数据信息列表
     */
    @PreAuthorize("@ss.hasPermi('teahouse:dietData:export')")
    @Log(title = "饮食数据信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DietData dietData)
    {
        List<DietData> list = dietDataService.selectDietDataList(dietData);
        ExcelUtil<DietData> util = new ExcelUtil<DietData>(DietData.class);
        util.exportExcel(response, list, "饮食数据信息数据");
    }

    /**
     * 获取饮食数据信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('teahouse:dietData:query')")
    @GetMapping(value = "/{dataId}")
    public AjaxResult getInfo(@PathVariable("dataId") Long dataId)
    {
        return success(dietDataService.selectDietDataByDataId(dataId));
    }

    /**
     * 新增饮食数据信息
     */
    @PreAuthorize("@ss.hasPermi('teahouse:dietData:add')")
    @Log(title = "饮食数据信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DietData dietData)
    {
        return toAjax(dietDataService.insertDietData(dietData));
    }

    /**
     * 修改饮食数据信息
     */
    @PreAuthorize("@ss.hasPermi('teahouse:dietData:edit')")
    @Log(title = "饮食数据信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DietData dietData)
    {
        return toAjax(dietDataService.updateDietData(dietData));
    }

    /**
     * 删除饮食数据信息
     */
    @PreAuthorize("@ss.hasPermi('teahouse:dietData:remove')")
    @Log(title = "饮食数据信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dataIds}")
    public AjaxResult remove(@PathVariable Long[] dataIds)
    {
        return toAjax(dietDataService.deleteDietDataByDataIds(dataIds));
    }
}
